package com.sxran.im.handler;

import cn.hutool.core.util.ClassUtil;
import com.alibaba.fastjson.JSONObject;

public abstract class AbstractCmdHandler<T> implements  CmdHandler{
    private Class<?> tClass;
    AbstractCmdHandler(){
        tClass = ClassUtil.getTypeArgument(this.getClass());
    }
    public String doService(String json){
        T object =  (T) JSONObject.parseObject(json, tClass);
        Object beanService = doBeanService(object);
        return JSONObject.toJSONString(beanService);
    }
    public abstract Object doBeanService(T bean);
}
